const app = getApp();
import routerConfig from '../../page/router';
import routerInit from 'miniapp-router';
Component({
  mixins: [],
  data: {
    name:'',
    title:'',
    member:'',
    sales_id:'',
    labelCol: { fixedSpan: 4 },
    wrapperCol: { span: 20 },
  },
  props: {},
  didMount() {
    var app = getApp();
    routerInit.call(this, routerConfig);  //跳转页面初始化
    var params = this.$page.$router.params;
    console.log(this.$page.$router.params)
    this.setData({
      title:params.title,
      sales_id:params.sales_id
    })
  },
  didUpdate() {
  },
  didUnmount() {
  },
  methods: {
    //创建活动
    handleSubmit() {
      if (!this.data.member) {
        my.alert({ content: '请选择通知人群!' });
        return false;
      }
      var apiurl = 'App.ShopRedsSales.Save';
      var params = {
        "member": this.data.member,
        "name": this.data.name,
      };
      console.log(params)
      var app = getApp();
      var self = this;
      my.confirm({
        title: '确认',
        content: '确定立即发送短信通知吗?',
        success: (result) => {
          if (result.confirm) {
            app.xdapis(apiurl, params, function (e) {
              my.hideLoading();
              my.alert({ title: '发送成功!' });
              self.toActList();
            });
          }
        }
      });
      
       
    },
     onChange(e) {
      let {
        detail: { value },
        currentTarget: { dataset }
      } = e;
      let { name } = dataset;
      console.log(name + ' onChange:', value);
      this.setData({ [name]: value });
    },
  },
});
